<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Start" href="index.html">
<link rel="previous" href="Bigarray.html">
<link rel="next" href="Builtin_attributes.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Arg" rel="Chapter" href="Arg.html">
<link title="Arg_helper" rel="Chapter" href="Arg_helper.html">
<link title="Array" rel="Chapter" href="Array.html">
<link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html">
<link title="Ast_helper" rel="Chapter" href="Ast_helper.html">
<link title="Ast_invariants" rel="Chapter" href="Ast_invariants.html">
<link title="Ast_iterator" rel="Chapter" href="Ast_iterator.html">
<link title="Ast_mapper" rel="Chapter" href="Ast_mapper.html">
<link title="Asttypes" rel="Chapter" href="Asttypes.html">
<link title="Attr_helper" rel="Chapter" href="Attr_helper.html">
<link title="Bigarray" rel="Chapter" href="Bigarray.html">
<link title="Buffer" rel="Chapter" href="Buffer.html">
<link title="Builtin_attributes" rel="Chapter" href="Builtin_attributes.html">
<link title="Bytes" rel="Chapter" href="Bytes.html">
<link title="BytesLabels" rel="Chapter" href="BytesLabels.html">
<link title="Callback" rel="Chapter" href="Callback.html">
<link title="CamlinternalFormat" rel="Chapter" href="CamlinternalFormat.html">
<link title="CamlinternalFormatBasics" rel="Chapter" href="CamlinternalFormatBasics.html">
<link title="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.html">
<link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html">
<link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html">
<link title="Ccomp" rel="Chapter" href="Ccomp.html">
<link title="Char" rel="Chapter" href="Char.html">
<link title="Clflags" rel="Chapter" href="Clflags.html">
<link title="Complex" rel="Chapter" href="Complex.html">
<link title="Condition" rel="Chapter" href="Condition.html">
<link title="Config" rel="Chapter" href="Config.html">
<link title="Consistbl" rel="Chapter" href="Consistbl.html">
<link title="Depend" rel="Chapter" href="Depend.html">
<link title="Digest" rel="Chapter" href="Digest.html">
<link title="Docstrings" rel="Chapter" href="Docstrings.html">
<link title="Dynlink" rel="Chapter" href="Dynlink.html">
<link title="Ephemeron" rel="Chapter" href="Ephemeron.html">
<link title="Event" rel="Chapter" href="Event.html">
<link title="Filename" rel="Chapter" href="Filename.html">
<link title="Format" rel="Chapter" href="Format.html">
<link title="Gc" rel="Chapter" href="Gc.html">
<link title="Genlex" rel="Chapter" href="Genlex.html">
<link title="Graphics" rel="Chapter" href="Graphics.html">
<link title="GraphicsX11" rel="Chapter" href="GraphicsX11.html">
<link title="Hashtbl" rel="Chapter" href="Hashtbl.html">
<link title="Identifiable" rel="Chapter" href="Identifiable.html">
<link title="Int32" rel="Chapter" href="Int32.html">
<link title="Int64" rel="Chapter" href="Int64.html">
<link title="Lazy" rel="Chapter" href="Lazy.html">
<link title="Lexer" rel="Chapter" href="Lexer.html">
<link title="Lexing" rel="Chapter" href="Lexing.html">
<link title="List" rel="Chapter" href="List.html">
<link title="ListLabels" rel="Chapter" href="ListLabels.html">
<link title="Location" rel="Chapter" href="Location.html">
<link title="Longident" rel="Chapter" href="Longident.html">
<link title="Map" rel="Chapter" href="Map.html">
<link title="Marshal" rel="Chapter" href="Marshal.html">
<link title="Misc" rel="Chapter" href="Misc.html">
<link title="MoreLabels" rel="Chapter" href="MoreLabels.html">
<link title="Mutex" rel="Chapter" href="Mutex.html">
<link title="Nativeint" rel="Chapter" href="Nativeint.html">
<link title="Numbers" rel="Chapter" href="Numbers.html">
<link title="Obj" rel="Chapter" href="Obj.html">
<link title="Oo" rel="Chapter" href="Oo.html">
<link title="Parse" rel="Chapter" href="Parse.html">
<link title="Parser" rel="Chapter" href="Parser.html">
<link title="Parsetree" rel="Chapter" href="Parsetree.html">
<link title="Parsing" rel="Chapter" href="Parsing.html">
<link title="Pervasives" rel="Chapter" href="Pervasives.html">
<link title="Pparse" rel="Chapter" href="Pparse.html">
<link title="Pprintast" rel="Chapter" href="Pprintast.html">
<link title="Printast" rel="Chapter" href="Printast.html">
<link title="Printexc" rel="Chapter" href="Printexc.html">
<link title="Printf" rel="Chapter" href="Printf.html">
<link title="Profile" rel="Chapter" href="Profile.html">
<link title="Queue" rel="Chapter" href="Queue.html">
<link title="Random" rel="Chapter" href="Random.html">
<link title="Scanf" rel="Chapter" href="Scanf.html">
<link title="Set" rel="Chapter" href="Set.html">
<link title="Simplif" rel="Chapter" href="Simplif.html">
<link title="Sort" rel="Chapter" href="Sort.html">
<link title="Spacetime" rel="Chapter" href="Spacetime.html">
<link title="Stack" rel="Chapter" href="Stack.html">
<link title="StdLabels" rel="Chapter" href="StdLabels.html">
<link title="Str" rel="Chapter" href="Str.html">
<link title="Stream" rel="Chapter" href="Stream.html">
<link title="String" rel="Chapter" href="String.html">
<link title="StringLabels" rel="Chapter" href="StringLabels.html">
<link title="Strongly_connected_components" rel="Chapter" href="Strongly_connected_components.html">
<link title="Syntaxerr" rel="Chapter" href="Syntaxerr.html">
<link title="Sys" rel="Chapter" href="Sys.html">
<link title="Targetint" rel="Chapter" href="Targetint.html">
<link title="Tbl" rel="Chapter" href="Tbl.html">
<link title="Terminfo" rel="Chapter" href="Terminfo.html">
<link title="Thread" rel="Chapter" href="Thread.html">
<link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html">
<link title="Typemod" rel="Chapter" href="Typemod.html">
<link title="Uchar" rel="Chapter" href="Uchar.html">
<link title="Unix" rel="Chapter" href="Unix.html">
<link title="UnixLabels" rel="Chapter" href="UnixLabels.html">
<link title="Warnings" rel="Chapter" href="Warnings.html">
<link title="Weak" rel="Chapter" href="Weak.html"><title>Buffer</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Bigarray.html" title="Bigarray">Previous</a>
&nbsp;<a class="up" href="index.html" title="Index">Up</a>
&nbsp;<a class="post" href="Builtin_attributes.html" title="Builtin_attributes">Next</a>
</div>
<h1>Module <a href="type_Buffer.html">Buffer</a></h1>

<pre><span id="MODULEBuffer"><span class="keyword">module</span> Buffer</span>: <code class="code"><span class="keyword">sig</span></code> <a href="Buffer.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
<div class="info-desc">
<p>Extensible buffers.</p>

<p>This module implements buffers that automatically expand
   as necessary.  It provides accumulative concatenation of strings
   in quasi-linear time (instead of quadratic time when strings are
   concatenated pairwise).</p>
</div>
</div>
<hr width="100%">

<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> </pre>
<div class="info ">
<div class="info-desc">
<p>The abstract type of buffers.</p>
</div>
</div>


<pre><span id="VALcreate"><span class="keyword">val</span> create</span> : <code class="type">int -> <a href="Buffer.html#TYPEt">t</a></code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">create&nbsp;n</code> returns a fresh buffer, initially empty.
   The <code class="code">n</code> parameter is the initial size of the internal byte sequence
   that holds the buffer contents. That byte sequence is automatically
   reallocated when more than <code class="code">n</code> characters are stored in the buffer,
   but shrinks back to <code class="code">n</code> characters when <code class="code">reset</code> is called.
   For best performance, <code class="code">n</code> should be of the same order of magnitude
   as the number of characters that are expected to be stored in
   the buffer (for instance, 80 for a buffer that holds one output
   line).  Nothing bad will happen if the buffer grows beyond that
   limit, however. In doubt, take <code class="code">n&nbsp;=&nbsp;16</code> for instance.
   If <code class="code">n</code> is not between 1 and <a href="Sys.html#VALmax_string_length"><code class="code"><span class="constructor">Sys</span>.max_string_length</code></a>, it will
   be clipped to that interval.</p>
</div>
</div>

<pre><span id="VALcontents"><span class="keyword">val</span> contents</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> string</code></pre><div class="info ">
<div class="info-desc">
<p>Return a copy of the current contents of the buffer.
    The buffer itself is unchanged.</p>
</div>
</div>

<pre><span id="VALto_bytes"><span class="keyword">val</span> to_bytes</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> bytes</code></pre><div class="info ">
<div class="info-desc">
<p>Return a copy of the current contents of the buffer.
    The buffer itself is unchanged.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>

<pre><span id="VALsub"><span class="keyword">val</span> sub</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> int -> string</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Buffer</span>.sub&nbsp;b&nbsp;off&nbsp;len</code> returns a copy of <code class="code">len</code> bytes from the
    current contents of the buffer <code class="code">b</code>, starting at offset <code class="code">off</code>.</p>

<p>Raise <code class="code"><span class="constructor">Invalid_argument</span></code> if <code class="code">srcoff</code> and <code class="code">len</code> do not designate a valid
    range of <code class="code">b</code>.</p>
</div>
</div>

<pre><span id="VALblit"><span class="keyword">val</span> blit</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> bytes -> int -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Buffer</span>.blit&nbsp;src&nbsp;srcoff&nbsp;dst&nbsp;dstoff&nbsp;len</code> copies <code class="code">len</code> characters from
   the current contents of the buffer <code class="code">src</code>, starting at offset <code class="code">srcoff</code>
   to <code class="code">dst</code>, starting at character <code class="code">dstoff</code>.</p>

<p>Raise <code class="code"><span class="constructor">Invalid_argument</span></code> if <code class="code">srcoff</code> and <code class="code">len</code> do not designate a valid
   range of <code class="code">src</code>, or if <code class="code">dstoff</code> and <code class="code">len</code> do not designate a valid
   range of <code class="code">dst</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 3.11.2</li>
</ul>
</div>

<pre><span id="VALnth"><span class="keyword">val</span> nth</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> char</code></pre><div class="info ">
<div class="info-desc">
<p>Get the n-th character of the buffer. Raise <code class="code"><span class="constructor">Invalid_argument</span></code> if
    index out of bounds</p>
</div>
</div>

<pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int</code></pre><div class="info ">
<div class="info-desc">
<p>Return the number of characters currently contained in the buffer.</p>
</div>
</div>

<pre><span id="VALclear"><span class="keyword">val</span> clear</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Empty the buffer.</p>
</div>
</div>

<pre><span id="VALreset"><span class="keyword">val</span> reset</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Empty the buffer and deallocate the internal byte sequence holding the
   buffer contents, replacing it with the initial internal byte sequence
   of length <code class="code">n</code> that was allocated by <a href="Buffer.html#VALcreate"><code class="code"><span class="constructor">Buffer</span>.create</code></a> <code class="code">n</code>.
   For long-lived buffers that may have grown a lot, <code class="code">reset</code> allows
   faster reclamation of the space used by the buffer.</p>
</div>
</div>

<pre><span id="VALadd_char"><span class="keyword">val</span> add_char</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> char -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_char&nbsp;b&nbsp;c</code> appends the character <code class="code">c</code> at the end of buffer <code class="code">b</code>.</p>
</div>
</div>

<pre><span id="VALadd_utf_8_uchar"><span class="keyword">val</span> add_utf_8_uchar</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Uchar.html#TYPEt">Uchar.t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_utf_8_uchar&nbsp;b&nbsp;u</code> appends the <a href="https://tools.ietf.org/html/rfc3629">
    UTF-8</a> encoding of <code class="code">u</code> at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.06.0</li>
</ul>
</div>

<pre><span id="VALadd_utf_16le_uchar"><span class="keyword">val</span> add_utf_16le_uchar</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Uchar.html#TYPEt">Uchar.t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_utf_16le_uchar&nbsp;b&nbsp;u</code> appends the
    <a href="https://tools.ietf.org/html/rfc2781">UTF-16LE</a> encoding of <code class="code">u</code>
    at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.06.0</li>
</ul>
</div>

<pre><span id="VALadd_utf_16be_uchar"><span class="keyword">val</span> add_utf_16be_uchar</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Uchar.html#TYPEt">Uchar.t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_utf_16be_uchar&nbsp;b&nbsp;u</code> appends the
    <a href="https://tools.ietf.org/html/rfc2781">UTF-16BE</a> encoding of <code class="code">u</code>
    at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.06.0</li>
</ul>
</div>

<pre><span id="VALadd_string"><span class="keyword">val</span> add_string</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> string -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_string&nbsp;b&nbsp;s</code> appends the string <code class="code">s</code> at the end of buffer <code class="code">b</code>.</p>
</div>
</div>

<pre><span id="VALadd_bytes"><span class="keyword">val</span> add_bytes</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> bytes -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_bytes&nbsp;b&nbsp;s</code> appends the byte sequence <code class="code">s</code> at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>

<pre><span id="VALadd_substring"><span class="keyword">val</span> add_substring</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> string -> int -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_substring&nbsp;b&nbsp;s&nbsp;ofs&nbsp;len</code> takes <code class="code">len</code> characters from offset
   <code class="code">ofs</code> in string <code class="code">s</code> and appends them at the end of buffer <code class="code">b</code>.</p>
</div>
</div>

<pre><span id="VALadd_subbytes"><span class="keyword">val</span> add_subbytes</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> bytes -> int -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_subbytes&nbsp;b&nbsp;s&nbsp;ofs&nbsp;len</code> takes <code class="code">len</code> characters from offset
    <code class="code">ofs</code> in byte sequence <code class="code">s</code> and appends them at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>

<pre><span id="VALadd_substitute"><span class="keyword">val</span> add_substitute</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> (string -> string) -> string -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_substitute&nbsp;b&nbsp;f&nbsp;s</code> appends the string pattern <code class="code">s</code> at the end
   of buffer <code class="code">b</code> with substitution.
   The substitution process looks for variables into
   the pattern and substitutes each variable name by its value, as
   obtained by applying the mapping <code class="code">f</code> to the variable name. Inside the
   string pattern, a variable name immediately follows a non-escaped
   <code class="code">$</code> character and is one of the following:</p>
<ul>
<li>a non empty sequence of alphanumeric or <code class="code">_</code> characters,</li>
<li>an arbitrary sequence of characters enclosed by a pair of
   matching parentheses or curly brackets.
   An escaped <code class="code">$</code> character is a <code class="code">$</code> that immediately follows a backslash
   character; it then stands for a plain <code class="code">$</code>.
   Raise <code class="code"><span class="constructor">Not_found</span></code> if the closing character of a parenthesized variable
   cannot be found.</li>
</ul>
</div>
</div>

<pre><span id="VALadd_buffer"><span class="keyword">val</span> add_buffer</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Buffer.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_buffer&nbsp;b1&nbsp;b2</code> appends the current contents of buffer <code class="code">b2</code>
   at the end of buffer <code class="code">b1</code>.  <code class="code">b2</code> is not modified.</p>
</div>
</div>

<pre><span id="VALadd_channel"><span class="keyword">val</span> add_channel</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Pervasives.html#TYPEin_channel">in_channel</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_channel&nbsp;b&nbsp;ic&nbsp;n</code> reads at most <code class="code">n</code> characters from the
   input channel <code class="code">ic</code> and stores them at the end of buffer <code class="code">b</code>.
   Raise <code class="code"><span class="constructor">End_of_file</span></code> if the channel contains fewer than <code class="code">n</code>
   characters. In this case, the characters are still added to
   the buffer, so as to avoid loss of data.</p>
</div>
</div>

<pre><span id="VALoutput_buffer"><span class="keyword">val</span> output_buffer</span> : <code class="type"><a href="Pervasives.html#TYPEout_channel">out_channel</a> -> <a href="Buffer.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">output_buffer&nbsp;oc&nbsp;b</code> writes the current contents of buffer <code class="code">b</code>
   on the output channel <code class="code">oc</code>.</p>
</div>
</div>

<pre><span id="VALtruncate"><span class="keyword">val</span> truncate</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">truncate&nbsp;b&nbsp;len</code> truncates the length of <code class="code">b</code> to <code class="code">len</code>
  Note: the internal byte sequence is not shortened.
  Raise <code class="code"><span class="constructor">Invalid_argument</span></code> if <code class="code">len&nbsp;&lt;&nbsp;0</code> or <code class="code">len&nbsp;&gt;&nbsp;length&nbsp;b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.05.0</li>
</ul>
</div>
</body></html>